import han.chensing.latos.file.LatosFile;
import han.chensing.latos.game.level.LatosLevel;
import han.chensing.latos.game.level.LevelTranslator;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;

public class Test {
    @org.junit.Test
    public void test(){
        try {
            LatosFile latosFile=new LatosFile();
            ArrayList<LatosFile.LatosChunk> chunks = latosFile.getChunks();
            LatosFile.LatosChunk chunk=new LatosFile.LatosChunk();
            ArrayList<LatosFile.LatosEvent> events = chunk.getEvents();
            events.add(new LatosFile.LatosEvent(){{
                setEvent(Event.Note);
                setDeltaTime(1);
                setContents(new Object[]{1,new byte[]{
                        (byte)0xB1,
                        0x00,0x01,
                        0x01,
                        0x00,0x14}});
            }});
            events.add(new LatosFile.LatosEvent(){{
                setEvent(Event.Line);
                setDeltaTime(0);
                setContents(new Object[]{0,new byte[]{
                        (byte)0xB1,
                        0x00,0x01,
                        0x01,
                        0x00,0x14}});
            }});
            chunks.add(chunk);
            File file=new File("D:\\GAMES\\MC\\1.7.10\\Test.lat");
            FileOutputStream fileOutputStream=new FileOutputStream(file);
            latosFile.toStream(fileOutputStream);
            fileOutputStream.close();
            FileInputStream fileInputStream=new FileInputStream(file);
            LatosFile latosFile1 = LatosFile.fromStream(fileInputStream);
            System.out.println(latosFile1);
            fileInputStream.close();
            assert latosFile1 != null;
            LatosLevel latosLevel = LevelTranslator.genLevelFromFile(latosFile1);
            System.out.println(latosLevel);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
